/**
  EG4Sim project, Anyang Normal University && IMP-CAS
  \class EG4TA
  \brief the reaction target
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2023-11-22
  \date 2023-11-22 last modified
  \copyright Copyright (c) 2023-2024 IMP-CAS with LGPLv3 LICENSE
*/

#include "EG4TA.h"
#include "G4Tubs.hh"
#include "G4NistManager.hh"
#include "G4LogicalVolume.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4SystemOfUnits.hh"

using CLHEP::pi;

EG4TA::EG4TA() : EG4Det(){
  auto nist = G4NistManager::Instance();
  G4Material *m = nullptr;
  double d = 0., dTA = 0; // d: diameter, dTA: thickness

// #define C_TA
// #define Be_TA
#define D2O_TA

#ifdef C_TA
  m = nist->BuildMaterialWithNewDensity("GRAPHITE180", "G4_GRAPHITE_POROUS",
    1.7997839*g/cm3);
  dTA = 5.*mm;
  d = 50.*mm;
#elifdef Be_TA
  m = nist->BuildMaterialWithNewDensity("Be1848", "G4_Be", 1.848*g/cm3);
  dTA = 10.*mm;
  d = 50.*mm;
#elifdef D2O_TA
  G4Element *elD = new G4Element("Deuteron", "D", 1., 2.0141*g/mole);
  G4Element *elO = nist->FindElement(8);
  G4Material *D2O = new G4Material("D2O", 1.1079*g/cm3, 2);
  D2O->AddElement(elD, 2); // 2: 2 atoms in D2O
  D2O->AddElement(elO, 1);
  m = D2O;
  dTA = 290.*mm;
  d = 80.*mm;
#endif

  fLV = new G4LogicalVolume(new G4Tubs("TA", 0., d/2., dTA/2., 0., 2.*pi), m, "TA");
  SetColor(1., 0., 0.);
} // end ctor

EG4TA::~EG4TA(){}
